package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.dao.ProductMapper;
import com.qf.entity.Product;
import com.qf.enums.PageEnum;
import com.qf.service.ProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chen
 * @version 1.0
 * @date 2019/10/24 18:22
 */
@Service
public class ProductServiceImpl implements ProductService {
    @Resource
    private ProductMapper productMapper;
    @Override
    public List<Product> getProducts(Integer pageIndex) {
        PageHelper.startPage(pageIndex, PageEnum.TEN.getPageIndex());
        List<Product> productList = productMapper.getProducts(pageIndex);
        PageInfo<Product> pageInfo = new PageInfo<>(productList);
        return pageInfo.getList();
    }

    @Override
    public Product getProductByProductId(Integer productId) {
        Product product= productMapper.getProductByProductId(productId);
        return product;
    }
}
